<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/include/head.jsp" %>
<html>
  <head>
    <title>add</title>
    <script type="text/javascript">
    	//用户检测
		$(function(){
			$('#username').blur(function(){
				var username = $('#username').val();
				//非空检测
				if(username == ""){
					$('#userInfo').html('用户名不能为空');
					return;
				} else {
					//ajax检测
				    $("#userInfo").html("正在检测...");
				    $.post(
						"/Integrate/isRepeatUsers.do",
						{"username": username},
						function(data){
							if(data){
								$("#userInfo").html("用户已存在");
							}else{
								$("#userInfo").html("可以使用");
							}
						}
					);
				}
			})
		});
    </script>
  </head>
  
  <body>
	<h1 align="center">Add:</h1><hr/>
		<center> 
			<form action="<%=contextPath%>/add.do" method="post">
				<table align="center" >
					<tr>
						<td align="center">UserName：</td>
						<td>
							<input type="text" name="user.username" id="username" />
							<div>
								<span style="color: red" id="userInfo"></span>
							</div>
						</td>
					</tr>
					<tr>
						<td align="center">Password：</td>
						<td><input type="text" name="user.password" /></td>
					</tr>
					<tr>
						<td align="center">Email：</td>
						<td><input type="text" name="user.email" /></td>
					</tr>
					<tr>
						<td align="center">Age：</td>
						<td><input type="text" name="user.age" /></td>
					</tr>
					<tr>
						<td align="center">Sex：</td>
						<td>
							<input type="radio" name="user.sex" value="1" />男
							<input type="radio" name="user.sex" value="0" />女
						</td>
					</tr>
				</table>
				<div align="center">
					<span id="upinfo" style="color: red">
						<s:property value="#session['addError']"/>
					</span>
				</div>
				<input type="submit" value="add" />
				<input type="button" onclick="javascript:history.back(-1);" value="back"/>
			</form>
		</center>
	</body>
</html>
